//
//  videorootViewController.m
//  iNews
//
//  Created by lanou3g on 14-12-10.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "videorootViewController.h"
#import "videosView.h"
#import "Reachability.h"
#import "movieHandel.h"
@interface videorootViewController ()<UIScrollViewDelegate>

@property(nonatomic,retain)videosView *rootvideo;
@end

@implementation videorootViewController

-(void)dealloc{

    [_rootvideo release];
    [super dealloc];

}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
       
        self.title = @"视频";
        self.rootvideo = [[[videosView alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];
    }
    return self;
}

-(void)loadView{
    self.view = self.rootvideo;

}
- (void)viewDidLoad
{
    
    
    
    [super viewDidLoad];
    

    
    //给segment添加事件
    [self.rootvideo.segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    //设置代理
    
    self.rootvideo.scrollV.delegate = self;
   
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//点击segment,Segment与scrollv联动
-(void)segmentAction:(UISegmentedControl*)sender
{
    [UIView animateWithDuration:0 animations:^{
        self.rootvideo.scrollV.contentOffset=CGPointMake(sender.selectedSegmentIndex*[UIScreen mainScreen].bounds.size.width, 0);
    }];
}




//滑动scrollview时与segment联动
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    
    self.rootvideo.segment.selectedSegmentIndex=self.rootvideo.scrollV.contentOffset.x/[UIScreen mainScreen].bounds.size.width;
    
    
    
}


@end
